New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

tonal-distance

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

tonal-distance

Find distances between musical notes

  • 0.50.2
  • npm
  • Socket score

Version published
Weekly downloads
657
decreased by-37.84%
Maintainers
1
Weekly downloads
 
Created
Source

tonal-distance npm version

tonal

tonal-distance is a collection of functions to find distances between music notes.

This is part of tonal music theory library.

You can install via npm: npm i --save tonal-distance

API Reference

distance(from, to)Interval

Find distance between two pitches. Both pitches MUST be of the same type. Distances between pitch classes always returns ascending intervals. Distances between intervals substract one from the other.

distInSemitones(from, to)Integer

Get the distance between two notes in semitones

interval()

An alias for distance

distance(from, to) ⇒ Interval

Find distance between two pitches. Both pitches MUST be of the same type. Distances between pitch classes always returns ascending intervals. Distances between intervals substract one from the other.

Kind: global function
Returns: Interval - the distance between pitches

ParamTypeDescription
fromPitch | Stringdistance from
toPitch | Stringdistance to

Example

import { distance } from 'tonal-distance'
distance('C2', 'C3') // => 'P8'
distance('G', 'B') // => 'M3'
// or use tonal
var tonal = require('tonal')
tonal.distance('M2', 'P5') // => 'P4'

distInSemitones(from, to) ⇒ Integer

Get the distance between two notes in semitones

Kind: global function
Returns: Integer - the distance in semitones or null if not valid notes

ParamTypeDescription
fromString | Pitchfirst note
toString | Pitchlast note

Example

import { distInSemitones } from 'tonal-distance'
distInSemitones('C3', 'A2') // => -3
// or use tonal
tonal.distInSemitones('C3', 'G3') // => 7

interval()

An alias for distance

Kind: global function

Keywords

FAQs

Package last updated on 10 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc